home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameVehicle.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
6KB
|
181 lines
class GameVehicle extends GameCharacter
{
var classID = SSGlobal.CLSID_VEHICLE;
var assetID = "ATV";
var canTake = true;
var maxWalkForce = 2400;
var animationLabels = ["static","idle"];
var canCarry = false;
var canClimb = false;
var canSwing = false;
var canLockDisplayState = false;
var fuel = 1;
var fuelBurnRate = 0.06666;
var skidTime = 0;
var oldDX = 0;
var editor_isItem = true;
var editor_name = "ATV";
function GameVehicle()
{
super();
}
function onCollision(obj)
{
if(this.canTake && obj.classID == SSGlobal.CLSID_MAINCHAR)
{
if(obj.jumpTime)
{
return undefined;
}
this.owner = obj;
obj.controller.setControl(this);
this.velocity.x = obj.velocity.x * 0.5;
this.velocity.y = obj.velocity.y * 0.5;
}
}
function shiftFuel(v)
{
this.controller.fuel = this.fuel = Math.min(1,this.fuel + v);
}
function onAddToWorld()
{
this.originX = this.x;
this.originY = this.y;
}
function activate()
{
this.canTake = false;
GameSound.playSound("happy");
this.x = this.originX;
this.y = this.originY;
this.fuel = 1;
this.velocity.y = -1;
this.velocity.x = 0;
var _loc3_ = undefined;
var _loc2_ = _loc3_ = this.world.collections.fuel.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
_loc3_[_loc2_].setActive(true);
}
this.snd = new Sound(this.target);
this.snd.attachSound("ATVIdle");
this.snd.start(0,1048575);
this.keepInScene = true;
this.shield = this.owner.shield;
this.owner.onShieldEnd();
this.immune = this.immuneAtStart;
this.setAnimationState(1);
this.world.viewport.setWatch(this);
this.controller.fuel = this.fuel;
this.health = this.controller.health;
}
function deactivate()
{
this.setAnimationState(0);
this.owner.moveTo(this.x,this.y,0);
this.target._visible = true;
this.target._rotation = 0;
this.owner.shield = this.shield;
this.onShieldEnd();
this.snd.stop();
this.snd = null;
this.owner.velocity.x = this.velocity.x * 0.5;
this.owner.velocity.y = this.velocity.y * 0.5 - 300;
this.keepInScene = false;
var _loc3_ = undefined;
var _loc2_ = _loc3_ = this.world.collections.fuel.length;
while((_loc2_ = _loc2_ - 1) > -1)
{
_loc3_[_loc2_].setActive(false);
}
var _loc4_ = new SSParticle(this.assetID,4,new Vector(this.velocity.x * 0.75,this.velocity.y * 0.75,-160),this.velocity.x >= 0 ? 45 : -45,600);
_loc4_.alpha = false;
_loc4_.x = this.x;
_loc4_.y = this.y;
this.world.addObject(_loc4_);
_loc4_.target.a._xscale *= this.velocity.x >= 0 ? 1 : -1;
this.moveTo(this.originX,this.originY,0);
this.canTake = true;
}
function onUpdate(elapsed)
{
this.fuel = this.controller.fuel = Math.max(Math.min(this.fuel - elapsed * this.fuelBurnRate,1),0);
if(!this.fuel || this.controller.action)
{
this.controller.setControl(this.owner);
}
}
function hurt()
{
}
function updateDisplay(elapsed, vX, vY, kJump)
{
if(vX != this.oldDX)
{
this.oldDX = vX;
this.snd.stop();
this.snd.attachSound(!vX ? "ATVIdle" : "ATVRevved");
this.snd.start(0,1048575);
}
if(this.dispCanTurn && vX && vX != this.dispAxis)
{
this.directionX = this.dispTurn = vX;
if(this.jumpTime && this.skidTime + 0.5 < this.world.time)
{
this.skidTime = this.world.time;
GameSound.playSound("skid");
}
}
if(this.contactSurface && (this.contactSurface.props & 3) == 3)
{
this.target._rotation = Math.atan2(this.contactSurface.normal.x,- this.contactSurface.normal.y) / 3.141592653589793 * 180;
}
else
{
this.target._rotation += (Math.atan2(this.velocity.y,this.velocity.x * this.dispAxis) / 3.141592653589793 * 45 * this.dispAxis - this.target._rotation) * elapsed * 2;
}
var _loc4_ = this.velocity.__get__length() * elapsed * 2;
this.target.a.mc.frontRim._rotation = this.target.a.mc.rearRim._rotation += _loc4_;
if(this.dispStateChanged || this.dispTurn)
{
if(this.dispTurn)
{
if(this.dispTurn > 0)
{
if((this.dispAxis = Math.min(1,this.dispAxis += elapsed * 2 / this.dispTurnTime)) == 1)
{
this.dispTurn = 0;
}
}
else if((this.dispAxis = Math.max(-1,this.dispAxis -= elapsed * 2 / this.dispTurnTime)) == -1)
{
this.dispTurn = 0;
}
}
this.dispFrame = this.dispTurnFrames + Math.round(this.dispAxis * this.dispTurnFrames) + 1;
this.target.a.gotoAndStop(this.dispFrame);
}
this.dispStateChanged = false;
}
function onAddDisplay()
{
this.initColor();
this.target.gotoAndStop(1);
this.buildAnimationData();
}
function setDead(obj)
{
this.owner.health = this.controller.health = 0.01;
this.controller.setControl(this.owner);
this.owner.velocity.x = this.velocity.x;
this.owner.velocity.y = this.velocity.y - 800;
}
function endLevel(obj)
{
this.controller.setControl(this.owner);
this.owner.velocity.x = this.velocity.x * 0.5;
this.owner.velocity.y = this.velocity.y * 0.5;
this.owner.endLevel(obj);
}
}